package cn.lyjuan.dwz_manage.core.java.cst;


import cn.lyjuan.dwz_manage.core.java.util.NumberUtils;

import java.util.Properties;

/**
 * DWZ后台地址
 * Created by ly on 2015/5/19.
 */
public class DwzCst
{
    /**
     * DWZ 框架主项目地址
     */
    public static String dwzProjectUrl;

    /**
     * DWZ 后台分页：总数名称
     */
    public static String pageTotalcountName;

    /**
     * DWZ 后台分页：当前页名称
     */
    public static String pagePnName;

    /**
     * DWZ 后台分页：页大小名称
     */
    public static String pagePsName;

    /**
     * DWZ 后台分页：页大小默认值
     */
    public static int pagePsDefaultValue;

    /**
     * 编码
     */
    public static String charset;

    public DwzCst(Properties properties)
    {
        this.setDwzProjectUrl(properties.getProperty("dwzProjectUrl"));
        this.setPageTotalcountName(properties.getProperty("pageTotalcountName"));
        this.setPagePnName(properties.getProperty("pagePnName"));
        this.setPagePsName(properties.getProperty("pagePsName"));
        this.setPagePsDefaultValue(properties.getProperty("pagePsDefaultValue"));
        this.setCharset(properties.getProperty("charset"));
    }

    @Override
    public String toString()
    {
        return "DwzCst{" +
                "dwzProjectUrl='" + dwzProjectUrl + '\'' +
                ", pageTotalcountName='" + pageTotalcountName + '\'' +
                ", pagePnName='" + pagePnName + '\'' +
                ", pagePsName='" + pagePsName + '\'' +
                ", pagePsDefaultValue=" + pagePsDefaultValue +
                '}';
    }

    public void setDwzProjectUrl(String dwzProjectUrl)
    {
        DwzCst.dwzProjectUrl = dwzProjectUrl;
    }
    public void setPageTotalcountName(String pageTotalcountName) {DwzCst.pageTotalcountName = pageTotalcountName;}
    public void setPagePnName(String pagePnName)
    {
        DwzCst.pagePnName = pagePnName;
    }
    public void setPagePsName(String pagePsName)
    {
        DwzCst.pagePsName = pagePsName;
    }
    public void setPagePsDefaultValue(String pagePsDefaultValue)
    {
        if (!NumberUtils.isNumber(pagePsDefaultValue))
            this.pagePsDefaultValue = 30;
        else
            this.pagePsDefaultValue = Integer.parseInt(pagePsDefaultValue);
    }
    public static void setCharset(String charset)
    {
        DwzCst.charset = charset;
    }

    public String getDwzProjectUrl() {return dwzProjectUrl;}
    public String getPageTotalcountName() {return pageTotalcountName;}
    public String getPagePnName() {return pagePnName;}
    public String getPagePsName() {return pagePsName;}
    public int getPagePsDefaultValue() {return pagePsDefaultValue;}
    public String getCharset() {return charset;}
}

